package com.gzc.pm.ro;

import java.util.ArrayList;
import java.util.List;

import cn.skyclass.net.OperationResult;

import com.gzc.pm.bean.DetectioncardBean;
import com.gzc.pm.bean.JmDataBean;
import com.gzc.pm.bean.PfDataBean;
import com.gzc.pm.dao.DetectionCardDao;
import com.gzc.pm.dao.JmDataDao;
import com.gzc.pm.dao.PfDataDao;

public class DetectionCardRo {
	
	public List<DetectioncardBean> getByPrId(int prId, String sDateStr, String eDateStr){
		DetectionCardDao dao = new DetectionCardDao();
		List<DetectioncardBean> list = new ArrayList<DetectioncardBean>();
		if(prId == -1){//轮轴生产线 工序轮对压装检测质量
			List<PfDataBean> pfList = new PfDataDao().getByCondition(sDateStr, eDateStr);
			for(PfDataBean pf : pfList){
				DetectioncardBean dcBean = new DetectioncardBean();
				dcBean.setProductId(pf.getProductId());
				dcBean.setTestDate(pf.getTestDate());
				dcBean.setV1(pf.getYzdw());
				dcBean.setV2(pf.getLkyzd1());
				dcBean.setV3(pf.getLkyzd2());
				dcBean.setV4(pf.getLkccd1());
				dcBean.setV5(pf.getLkccd2());
				dcBean.setV6(pf.getLzyzd1());
				dcBean.setV7(pf.getLzyzd2());
				dcBean.setV8(pf.getLzccd1());
				dcBean.setV9(pf.getLzccd2());
				dcBean.setV10(pf.getGyl1());
				dcBean.setV11(pf.getGyl2());
				list.add(dcBean);
			}
			
		}else if(prId == -2) {//轮轴生产线 工序轴颈检测质量
			List<JmDataBean> jmList = new JmDataDao().getByCondition(sDateStr, eDateStr);
			for(JmDataBean jm : jmList){
				DetectioncardBean dcBean = new DetectioncardBean();
				dcBean.setProductId(jm.getProductId());
				dcBean.setTestDate(jm.getTestDate());
				dcBean.setV1(jm.getYzd1());
				dcBean.setV2(jm.getCcd1());
				dcBean.setV3(jm.getZj1());
				dcBean.setV4(jm.getYzd2());
				dcBean.setV5(jm.getCcd2());
				dcBean.setV6(jm.getZj2());
				dcBean.setV7(jm.getQxsd());
				dcBean.setV8(jm.getJjl());
				dcBean.setV9(jm.getQxshd());
				dcBean.setV10(jm.getMxshd());
				dcBean.setV11(jm.getSlzs());
				dcBean.setV12(jm.getGjzs());
				list.add(dcBean);
			}
			
		}else {
			list = dao.getByPrId(prId, sDateStr, eDateStr);
		}
		return list;
	}

	public List<DetectioncardBean> getInPrIds(String prIdsStr, String sDateStr, String eDateStr){
		DetectionCardDao dao = new DetectionCardDao();
		return dao.getInPrIds(prIdsStr, sDateStr, eDateStr);
	}
	
	public OperationResult add(DetectioncardBean bean){
		DetectionCardDao dao = new DetectionCardDao();
		return dao.add(bean);
	}
	
}
